package flst.ipiweb.struts.action.promotion;

import ipiwebprocess.PromotionProcess;
import ipiwebtransverse.Promotion;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class PromotionListeAction extends Action{
	
	private static PromotionProcess sPromotionProcess = new PromotionProcess();

	public ActionForward execute(ActionMapping mapping, 
			ActionForm form,
			HttpServletRequest request, 
			HttpServletResponse response)
			throws Exception {

		String retour = "";

		List<Promotion> liste = sPromotionProcess.listerPromotion();

		if (!liste.isEmpty()) {
			request.setAttribute("listePromotion", liste);
			retour = "promotion_ok";
		} else {
			retour = "promotion_ko";
		}

		return mapping.findForward(retour);
	}
}
